#ifndef PRESCRIPTIONDATABASE_H
#define PRESCRIPTIONDATABASE_H

#include "Database.h"

#include <QAbstractTableModel>

class Prescription
{
public:
    QDate prescribeDate, completeDate;
    QString prescriptionName, prescribedBy, comments;

    int refills;
};

/*!
 * @class PrescriptionDatabaseModel
 * @brief Stores prescription information in a model for use with QTableView.
 */

class PrescriptionDatabaseModel : public QAbstractTableModel
{
public:
    PrescriptionDatabaseModel();
    void setSource(QList<Prescription> * records);

    int rowCount(const QModelIndex &parent) const;
    int columnCount(const QModelIndex &parent) const;

    QVariant data(const QModelIndex &index, int role) const;
    QVariant headerData(int section, Qt::Orientation orientation, int role) const;

private:
    int rowNum, colNum;
    QList<Prescription> * prescriptions;
};

/*!
 * @addtogroup Database
 * @{
 * @class PrescriptionDatabase
 * @brief Manages prescription information loaded from the database.
 * @}
 */

class PrescriptionDatabase : protected Database
{
public:
    PrescriptionDatabase();

    bool addPrescription(const Prescription *p, int userId);

    QList<Prescription> * loadPrescriptions(int userId);

    PrescriptionDatabaseModel * getModel();

private:
    QList<Prescription> prescriptionList;

    PrescriptionDatabaseModel * model;
};

#endif // PRESCRIPTIONDATABASE_H
